package ltd.dujiabao.capability.common.dto;

/**
 * @author : DuJiabao
 * @Project : ddd-capability
 * @Time : 2024/4/7 20:21
 * @Desc :
 */
public class Result<T> {
    private int errorCode;
    private T result;

    public Result() {
    }

    public Result(int errorCode) {
        this.errorCode = errorCode;
    }

    public Result(int errorCode, T result) {
        this.errorCode = errorCode;
        this.result = result;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    @Override
    public String toString() {
        return "Result{" +
                "errorCode=" + errorCode +
                ", result=" + result +
                '}';
    }

    public boolean isSuccess() {
        return ErrorCodes.SUCCESS.getCode() == errorCode;
    }
}
